using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace ErkerTech.DeltaScope.View.Models
{
    public class MoveStruct
    {
        public int LeftMove;
        public int RightMove;

        public MoveStruct ()
        {
            LeftMove = -1;
            RightMove = -1;
        }

        public MoveStruct(int tnLeft, int tnRight)
        {
            LeftMove = tnLeft * -1;
            RightMove = tnRight * -1;
        }
    }

    public class LineInfo
    {
        public string Line;
        public int Top;
        public int Height;

        public LineInfo(string tsLine)
        {
            Line = tsLine;
            Top	= 0;
            Height = 0;
        }

        public LineInfo(string tsLine, int tnTop, int tnHeight)
        {
            Line = tsLine;
            Top = tnTop;
            Height = tnHeight;
        }
    }

    public class SideStructure
    {
        public string Text;
        public LineInfo [] ALines;
        public Rectangle Rect;

        public SideStructure(string tsText)
        {
            Text = tsText;
            Rect = Rectangle.Empty;
            ALines = ParseText(tsText);
        }

        public SideStructure ( IList<string> tsTextList )
        {
            Rect = Rectangle.Empty;

            var sb = new StringBuilder();
            for (var i = 0; i < tsTextList.Count; i++)
                sb.AppendLine(tsTextList[i]);

            Text = sb.ToString();
            ALines = ParseText(Text);
        }

        public void MoveRectTop(int tnTopDelta)
        {
            Rect = new Rectangle(Rect.Left, Rect.Top + tnTopDelta, Rect.Width, Rect.Height);
            foreach (var loLine in ALines)
                loLine.Top += tnTopDelta;
        }

        private static LineInfo[] ParseText(string tsText)
        {
            var loList = new List<LineInfo>();
            foreach (var lsLine in tsText.Split('\n'))
                loList.Add(new LineInfo(lsLine));

            return loList.ToArray();
        }
    }
}